<template>
  <div>
    <div class="count">
      <header>张三的商品</header>
      <ul>
        <li v-for="(item, index) in list" :key="index">
           <span>{{ item.name }}</span> <span>{{item.price}}</span>
           <el-input-number v-model="item.num" :min="1" :max="10" label="描述文字"></el-input-number>
           <i class="el-icon-circle-close" @click="del(index)"></i>
         </li>
      </ul>
      <div class="foot">
          <span>总价：￥{{allPirce}}</span>
          <span class="right">结算</span>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      list: [
        { id: 1, name: "TCL彩电", price: 1000, num: 1 },
        { id: 2, name: "机顶盒", price: 500, num: 1 },
        { id: 3, name: "海尔冰箱", price: 2000, num: 1 },
        { id: 4, name: "小米手机", price: 2000, num: 1 },
        { id: 5, name: "PPTV电视", price: 1000, num: 2 },
      ],
    };
  },
  computed:{
    allPirce(){
        let number = 0;
        this.list.forEach(item => {
            number+= item.price*item.num
        })
        return number
    }
  },
  methods:{
      del(i){
          this.list.splice(i,1)
      }
  }
};
</script>
<style lang="scss" scoped>
.count {
  width: 500px;
  margin: 100px auto;
  header{
      line-height: 50px;
      text-align: center;
      background: skyblue;
      color: #fff;
  }
  li{
      list-style: none;
      height: 50px;
      display: flex;
      align-items: center;
      border-bottom: 1px solid #cccc;
      justify-content: space-around;
  }
  .foot{
      background: orange;
      height: 50px;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      .right{
          width: 80px;
          text-align: center;
          background: red;
          line-height: 50px;
          margin-left: 20px;
      }
  }
}
</style>